<?php $this->load->view('common/header');?>

<body class="home_back">
<div class="home_main">
    <div class="login_box">
        <div class="label">销冠订单协同系统</div>
        <div class="list">
            <h1><img style="width: 240px;height: 284px" src="<?php echo $viewmulu;?>images/logo_1.png"></h1>
            <ul>
                <li>
                	<span class="input">
                    	<i class="ico ico_a"></i>
                    	<input placeholder="请输入手机号码" id="mobile">
                    </span>
                </li>
                <li>
                	<span class="code">
                    	<input placeholder="验证码" id="code">
                    </span>
                    <a href="javascript:;" class="code able" id="getCode">发送验证码</a>
                </li>
                <li class="nav">
                    <a href="javascript:;" class="log_in" id="doLogin">登 录</a>
<!--                    <a href="javascript:;" class="reg">加入我们</a>-->
                </li>
            </ul>
        </div>
    </div>
</div>
<!-- head [[-->
<!--]] head -->
<script type="text/javascript">
    var baseurl='<?php echo base_url()?>';
    $(document).on("click",'#getCode.able',function(){
        var phone = $("#mobile").val();
        if(phone == "" || undefined){
            layer.msg("请填写手机号");
            return false;
        }
        var URL= baseurl+"index.php/home/ajax_send_sms";
        $.getJSON(URL,{'mobile':phone},function(logJson) {
            layer.msg(logJson.msg);
        });
        $("#getCode").html("发送中..").removeClass('able');
        setTimeout(time,1000)
    })
    function time(){
        var time = 60;
        var countDown = setInterval(fun,1000);
        function fun(){
            --time;
            $('#getCode').html(time+'s后获取');
            if (time == 0) {
                clearInterval(countDown);
                $('#getCode').html('重新获取').addClass('able');
            }
        }
    }
    // 提交
    $("#doLogin").on("click",function(){

        var mobile = $("#mobile").val();
        var yzm = $("#code").val();
        var myreg = /^((\d{3}-\d{8}|\d{4}-\d{7,8})|(1[3|5|7|8][0-9]{9}))$/;
        if (mobile=="") {
            layer.msg('请填写手机号码');
            return false;
        }
        if(!myreg.test(mobile)){
            layer.msg("手机号格式不正确");
            return false;
        }
        if (yzm=="") {
            layer.msg('请填写手机验证码');
            return false;
        }
        var URL= baseurl+"index.php/home/sms_login_in";
        $.ajax({
            type: "post",
            url: URL,
            dataType:'json',
            data: {
                'mobile':mobile,
                'yzm':yzm,
                'csrf_test_name': ci_csrf_token()
            },
            success: function(data){
                if(data.code == 200){
                    layer.msg('登录成功', {
                        time: 1000, //1s后自动关闭
                        shade: 0.1
                    },function () {
                        window.location.href = "<?php echo site_url(V_URL.'home');?>";
                    });
                }else{
                    layer.msg(data.msg);
                    return false;
                }

            }
        });
    });
</script>
<!--]] main -->
<!-- coypright [[-->
<!--]] coypright -->
</body>
</html>
